module.exports = {
  getOrigin: function (...URL) {
    URL = Object.assign(...URL);
    return `${URL.protocol || 'http'}://${URL.origin}:${URL.port}`
  },
  getURL: function (...URL) {
    URL = Object.assign(...URL);
    return `${URL.protocol || 'http'}://${URL.origin}:${URL.port}${URL.name ? ('/' + URL.name) : (URL.appCode ? ('/' + URL.appCode): (URL.projectName ? ('/' + URL.projectName) : ''))}`
  },
  getSSO: function (SSO) {
    if(typeof SSO.PublicURL === 'undefined') {
      SSO.PublicURL = SSO.LocalURL;
    }
    let ssoOrigin = `${SSO.PublicURL.protocol || 'http'}://${SSO.PublicURL.origin}:${SSO.PublicURL.port}`;
    let ssoLogin  = `${ssoOrigin}/${SSO.URL.login.path}`;
    let ssoLogout = `${ssoOrigin}/${SSO.URL.logout.path}`;
    let ssoCheckTicket = `${ssoOrigin}/${SSO.URL.checkTicket.path}`;
    let login  = `/${SSO.URL.login.path}`;
    let logout = `/${SSO.URL.logout.path}`;
    let checkTicket = `/${SSO.URL.checkTicket.path}`;
    let checkTicketMethod  = SSO.URL.checkTicket.method;
    let loginMethod  = SSO.URL.login.method;
    let logoutMethod = SSO.URL.logout.method;
    return {
      login,
      logout,
      ssoOrigin,
      ssoLogin,
      ssoLogout,
      checkTicket,
      loginMethod,
      logoutMethod,
      checkTicketMethod
    }
  },
};